package com.pactera.madp.cp.service;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pactera.madp.admin.api.dto.WxEmpDto;
import com.pactera.madp.admin.api.vo.WxEmpVo;
import com.pactera.madp.common.core.util.R;
import com.pactera.madp.cp.api.em.permission.ReqPerEnum;
import com.pactera.madp.cp.api.entity.WorkEmployeeEntity;
import com.pactera.madp.cp.api.dto.emp.EmpIndexDTO;
import com.pactera.madp.cp.api.bo.EmpSearchConditionBO;
import com.pactera.madp.cp.api.dto.emp.WXEmployeeDTO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface IWorkEmployeeService extends IService<WorkEmployeeEntity> {

    void synWxEmployee(int corpId);

    void synSysUserAndDept(int corpId);

    void syncSysUser(int corpId, String wxUserId, String delFlag);

    R index(EmpIndexDTO req, ReqPerEnum permission, Page page);

    R indexWechat(EmpIndexDTO req, ReqPerEnum permission, Page page);

    EmpSearchConditionBO searchCondition();

    /**
     * 企业微信前端调用接口
     * @return
     */
    EmpSearchConditionBO searchConditionWechat();

    R changeUser(String wxUserId,String wxExternalUserid,String id);

    void insertEmployee(int corpId, WXEmployeeDTO dto);

    void updateEmpDeptIndex(int corpId, WXEmployeeDTO dto);

    void syncDepartment(int corpId);

    void syncEmployee(int corpId);

    void syncEmployeeStatistic(int corpId);

    /**
     * 查看通讯录表中是否存在当前手机号，然后绑定
     * @param mobile
     * @param logUserId
     */
    void  verifyEmployeeMobile(String mobile,Integer logUserId);

    WorkEmployeeEntity getWorkEmployeeInfo(Integer empId);

    WorkEmployeeEntity getWorkEmployeeInfo(String userId);

    List<WorkEmployeeEntity> getWorkEmployeeByLogUserId(Integer logUserId);

    List<WorkEmployeeEntity> getWorkEmployeeByUserId(String userId);

    String [] getEmployeeName(List<Integer> empIds);

    Map<Integer,String> getCorpEmployeeName(Integer corpId,List<Integer> empIds);

    Map<Integer,String> getEmployeeName(Integer corpId,List<Integer> empIds);

    JSONArray getCorpEmployeeName(Integer corpId, String searchKeyWords);

    Map<String,Integer> getCorpByUserId(Integer corpId);

    List<WorkEmployeeEntity> getWorkEmployeeByLogUserId(String userId, String corpId);

    List<WorkEmployeeEntity> getWorkEmployeeByCorpIdLogUserId(String corpId, String userId);

    List<WorkEmployeeEntity> getWorkEmployeesById(String ownerIdArr);

    List<WorkEmployeeEntity> getWorkEmployeesByCorpIdName(Integer corpId, String name,String clStr);

    List<WorkEmployeeEntity> getWorkEmployeesByCorpId(Integer corpId, String s);

    List<WorkEmployeeEntity> getWorkEmployeesByMobile(String phone, String clStr);

    List<WorkEmployeeEntity> getWorkEmployeeList(String page, String perPage, String clStr, String empIdArr);

    Page getWorkEmployeeList(Page page, String clStr, String empIdArr, String employeeId, String employeeName);

    List<WorkEmployeeEntity> getWorkEmployeesByCorpIdsWxUserId(Integer corpId, List<String> froms,List<String> tolists, String s);

    /**
     * 根据员工 id 列表获取员工微信 id
     */
    List<String> getWxEmpIdListByEmpIdList(List<Integer> empIdList);

    WorkEmployeeEntity getWorkEmployeeInfoByLogId(Integer userId);

    WorkEmployeeEntity getWorkEmployeeByWxUserId(String userId, String s);

    List<WorkEmployeeEntity> countWorkEmployeesByCorpId(Integer corpId);

    WorkEmployeeEntity getWorkEmployeeByCorpIdAndWxUserId(Integer corpId, String wxUserId);

    /**
     * 获取应用可见范围的成员
     * @param employeeName
     * @return
     */
    List<WorkEmployeeEntity> selectAgentEmployee(String employeeName);

    void exitExcel(HttpServletResponse response, OutputStream out);

    void excelErrorMsg(HttpServletResponse response, OutputStream out);

    R inputExcel(MultipartFile file );

    String getUserIdById(Integer id);

    String getNameById(Integer id);

    List<Integer> getAuthorityDept();

    int getMainDepartmentId(int corpId, int wxDepartmentId);

    WorkEmployeeEntity getCurrentStatus();

    R<WxEmpVo> getEmp(String wxUserId);

    R<Boolean> addEmployee(WxEmpDto dto);

    R<Boolean> updateEmployee(WxEmpDto dto);

    R<Boolean> deleteEmployee(String wxUserId);

    List<Integer> getAllowEmployeesByDeptIds(List<Integer> depts);

    Set<Integer> getEmployeeIds(List<Integer> wxDeptIds, List<String> userMobiles);

    List<Integer> getEmployeeIdsByDeptIds(List<Integer> deptIds);

    Integer getEmpIdByWxUserId(String wxUserId);

}
